<?php
class TagsController extends AppController{
    public function index(){
        $this->loadModel('News');
        $this->loadModel('Meta');
        parent::init();
        $slug = $this->params['slug'];
		$tags = $this->Meta->find('all', array(
            'fields' => array('Meta.newsId'),
            'conditions' => array('Tags.slug' => $slug),
        ));
		$news = array();
		foreach($tags as $tag){
			$new = $this->News->find('first', array(
				'order' => 'News.date DESC',
				'conditions' => array('News.newsId' => $tag['Meta']['newsId']),
			));
			array_push($news, $new);
		}
        $this->set('slug', $slug);
        $this->set('news', $news);
    }
}